from pyecharts import options as opts
from pyecharts.charts import Map
from pyecharts.globals import ThemeType
from demo.dataSource.Data import data

data1 = [list(z) for z in zip(data["省市地区"].to_list(), data["新增确诊"].to_list())]

data_xz = data.loc[data['新增确诊']==0,:]
data_xz1 = [list(z) for z in zip(data_xz["省市地区"].to_list(), data_xz["新增确诊"].to_list())]

map = (
    Map(init_opts=opts.InitOpts(width="700px",height="700px",theme=ThemeType.LIGHT))
    .add("",data1,"china")
    .set_series_opts(showLegendSymbol=False)
    .add("",data_xz1, "china", itemstyle_opts=opts.ItemStyleOpts(color="red",),)
    .set_global_opts(
        title_opts=opts.TitleOpts(
            title="各省市新增确诊分布情况",
            pos_top= '20%',pos_left='35%',
            title_textstyle_opts=opts.TextStyleOpts(color='#CCFFFF',)),
        visualmap_opts=opts.VisualMapOpts(is_piecewise = False,pos_top = '82%',pos_left = '30%',
                         orient = "horizontal",
                         range_text = ['以上', ' '],
                         range_color = ['#FFFFFF','#0099CC'],
                         max_ = 200,
                         item_width=30,
                         item_height=300,
                     ),
                    )
)
map.render("../outHTML/map.html")